commit 0c00511118404ab13139f0c869f488f30028ccb3
Author: Daniel Kolesa <daniel@octaforge.org>
Date:   Sun Oct 9 13:30:22 2022 +0200

    patch makefile for bmake, include cflags when linking

diff --git a/Makefile b/Makefile
index 71c11f1..93c63af 100644
--- a/Makefile
+++ b/Makefile
@@ -3,7 +3,7 @@
 # To compile with MinGW please run: mingw32-make -f Makefile.mingw
 
 # Include path where lua.h, luaconf.h and lauxlib.h reside:
-INCLUDES= -I/usr/local/include
+INCLUDES= -I$(CBUILD_TARGET_SYSROOT)/usr/include/lua5.1
 
 DEFINES=
 # Use this for the old ARM ABI with swapped FPA doubles.
@@ -11,14 +11,13 @@ DEFINES=
 #DEFINES= -DSWAPPED_DOUBLE
 
 # Lua executable name. Used to find the install path and for testing.
-LUA= lua
+LUA= lua5.1
 
 CC= gcc
-CCOPT= -O2 -fomit-frame-pointer
 CCWARN= -Wall
 SOCC= $(CC) -shared
 SOCFLAGS= -fPIC $(CCOPT) $(CCWARN) $(DEFINES) $(INCLUDES) $(CFLAGS)
-SOLDFLAGS= -fPIC $(LDFLAGS)
+SOLDFLAGS= -fPIC $(CCOPT) $(CCWARN) $(DEFINES) $(INCLUDES) $(CFLAGS) $(LDFLAGS)
 RM= rm -f
 INSTALL= install -p
 INSTALLPATH= $(LUA) installpath.lua
@@ -33,10 +32,10 @@ macosx:
 	$(MAKE) all "SOCC=MACOSX_DEPLOYMENT_TARGET=10.4 $(CC) -dynamiclib -single_module -undefined dynamic_lookup"
 
 $(MODNAME).o: $(MODNAME).c
-	$(CC) $(SOCFLAGS) -c -o $@ $<
+	$(CC) $(SOCFLAGS) -c -o $(MODNAME).o $(MODNAME).c
 
 $(MODSO): $(MODNAME).o
-	$(SOCC) $(SOLDFLAGS) -o $@ $<
+	$(SOCC) $(SOLDFLAGS) -o $(MODSO) $(MODNAME).o
 
 install: $(MODSO)
 	$(INSTALL) $< `$(INSTALLPATH) $(MODNAME)`
